package com.wanxi.service.Impl;

import com.wanxi.dao.Impl.SuggestDaoImpl;
import com.wanxi.dao.SuggestDao;
import com.wanxi.dto.ResultDto;
import com.wanxi.model.SuggestModel;
import com.wanxi.service.SuggestService;

/**
 * @author Li
 * @Date 2023/5/6 14:35
 */
public class SuggestServiceImpl implements SuggestService {

    private  SuggestDao suggestDao = new SuggestDaoImpl();
    public ResultDto add(SuggestModel suggestModel) {

//        return suggestDao.Add(suggestModel);
        return ResultDto.builder()
                .code(0)
                .msg("添加成功")
                .count(suggestDao.add(suggestModel))
                .build();
    }

    public ResultDto update(SuggestModel suggestModel) {

//        return suggestDao.Update(suggestModel);
        return ResultDto.builder()
                .code(0)
                .msg("修改成功")
                .count(suggestDao.update(suggestModel))
                .build();
    }

    public ResultDto delete(SuggestModel suggestModel) {

//        return suggestDao.Delete(suggestModel);
        return ResultDto.builder()
                .code(0)
                .msg("删除成功")
                .count(suggestDao.delete(suggestModel))
                .build();
    }


    public ResultDto findAll(SuggestModel suggestModel) {

//        return suggestDao.FindAll(suggestModel);
        return ResultDto.builder()
                .code(0)
                .msg("查询成功")
                .count(suggestDao.count(suggestModel))
                .data(suggestDao.findAll(suggestModel))
                .build();
    }

    public ResultDto findById(SuggestModel suggestModel) {
        return ResultDto.builder()
                .code(0)
                .msg("查询成功")
                .data(suggestDao.findById(suggestModel))
                .build();
    }

    @Override
    public Integer totalCount() {
        return suggestDao.totalCount();
    }
}
